import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { ClientsModule, Transport } from '@nestjs/microservices';
import { AppMessage } from './app.message';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CommonModule } from 'common/lib/utils/common.module';
import { EssayController } from './controller/essay.controller';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { EssayService } from './service/essay.service';
import { jwtConstants} from "common/lib/passport/constants"
import { EssayEntity} from "common/lib/entities/essay.entity"

@Module({
  imports: [
    ClientsModule.registerAsync([
      {
        name: 'basic-service',
        imports: [ConfigModule],
        useFactory: async (configService: ConfigService) => ({
          transport: Transport.TCP,
          options: {
            port:configService.get('basic.tport')
          },
        }),
        inject: [ConfigService],
      },
    ]),
    CommonModule,
    TypeOrmModule.forFeature([EssayEntity]),
  ],
  controllers: [AppController, AppMessage, EssayController],
  providers: [EssayService],
})
export class AppModule {}
